function $(id) {
    return document.getElementById(id);
}
$("reg").onclick = function () {
    let name = $("loginname").value;
    let p=$("pwd").value;
    let str = localStorage.getItem(name);
    if(!str){
        alert("用户名输入有误");
        return;
    }
    let user = JSON.parse(str);
    if(p!=user.pwd){
        alert("密码错误");
        return;
    }
    location.href="main.html";
}